***cleaning AJD3  ***** 
****lady lawyers project, 2024

clear 
set more off 

global Base "C:\Users\mrholman\MH Dropbox\Mirya Holman\Pipelines paper\Law school ambition study"
*global Base "C:\Users\HolmanMirya\MH Dropbox\Mirya Holman\Pipelines paper\Law school ambition study"

global Data "$Base\data\after the JD studies\After the JD, Wave 3"
global Merging "$Base/Mirya/merging"

global tt1 cells(b(star fmt(%-9.3f)) se(fmt(%-9.3f) par( [ ] )) blank) stats (r2 N, fmt(%9.2f %9.0g)) style(fixed) starlevel("*" 0.10 "**" 0.05 "***" 0.01)

use "$Data\after the JD studies\After the JD, Wave 3\35480-0001-Data.dta" , replace

cd "$Data"

**** cleaning **** 

gen gender =  0
replace gender = 1 if CGENDER == 2
gen age = AGE_BRAC
gen edu_debt_remaining = CQ058XBRAC
gen white = CQ064_5
gen pid = .
replace pid =1 if CQ060 == 1
replace pid = 2 if CQ060 ==2
replace pid = 3 if CQ060 == 3

gen ideo_social = CQ061A 
recode ideo_social 9=.
gen ideo_econ = CQ061B
recode ideo_econ 9=.

gen law_degree_year = CQ053AYR_ALL
recode law_degree_year 9999=.

gen any_debt_still = CQ057

gen married = 0
replace married = 1 if inrange(CQ067, 2,4)
replace married = . if CQ067 == 99

gen any_children = CQ072A 
recode any_children 9=.
gen n_children = CQ072B
recode n_children 9=.


foreach var of varlist CQ062A CQ062B CQ062C CQ062D CQ062E CQ062F CQ062G CQ062H CQ062I CQ062J CQ062K CQ062L CQ062M CQ062N CQ062O CQ062P CQ062Q {
	recode `var' 9=0
	gen `var'2 = 0
	replace `var'2 = 1 if `var' == 1
	recode `var' 2=1
}
egen participation_all = rowtotal (CQ062A CQ062B CQ062C CQ062D CQ062E CQ062F CQ062G CQ062H CQ062I CQ062J CQ062K CQ062L CQ062M CQ062N CQ062O CQ062P CQ062Q)

egen lead_all = rowtotal (CQ062A2 CQ062B2 CQ062C2 CQ062D2 CQ062E2 CQ062F2 CQ062G2 CQ062H2 CQ062I2 CQ062J2 CQ062K2 CQ062L2 CQ062M2 CQ062N2 CQ062O2 CQ062P2 CQ062Q2)

gen participation_gender = CQ062K
gen lead_gender = CQ062K2
gen participation_civic = CQ062M
gen lead_civic = CQ062M2
gen participation_polparty = CQ062A
gen lead_polparty = CQ062A2
gen participation_poladvoc = CQ062B
gen lead_poladvoc = CQ062B2
gen participation_pta = CQ062C
gen lead_pta = CQ062C

foreach var of varlist  CQ051A- CQ051L {
	recode `var' 9=.
}


gen employed = 0
replace employed = 1 if CQ001 == 1
rename CQ001B1 pt_child
rename CQ001B2 pt_family
rename CQ001CI1 unemploy_child
rename CQ001CI2 unemploy_family

gen law_rank = CRANKA
recode law_rank 9=. 

gen communal_law = 0
replace communal_law = 1 if inrange(CQ004, 5,8)

gen current_judge = 0
replace current_judge = 1 if CQ005 == 10
gen current_da = 0
replace current_da = 1 if CQ005 == 21
gen current_clerk = 0
replace current_clerk = 1 if CQ005 == 22

gen per_work_male= CQ023 
recode per_work_male 999=.

gen pro_bono_work = CQ022A 
gen pro_bono_nonwork = CQ022B 
gen pro_bono_poor = CQ022C1 
gen pro_bono_charity = CQ022C2 

foreach var of varlist CQ031A CQ031B CQ031C CQ031D CQ031E CQ031F CQ031G CQ031H {
	recode `var' 9=.
}

rename CQ031A network_committee
rename CQ031B network_consult
rename CQ031C network_lunch
rename CQ031D network_rectime
rename CQ031E network_publications
rename CQ031F network_associations
rename CQ031G network_orgs
rename CQ031H network_nonprofit

foreach var of varlist CQ035A CQ035B CQ035C CQ035D CQ035E CQ035F CQ035G CQ035H CQ035I CQ035J CQ035K CQ035L CQ035M CQ035N CQ035O CQ035P CQ035Q {
	recode `var' 9=.
}

egen agentic_goals = rowmean(CQ051A CQ051C CQ051D CQ051H CQ051I CQ051J CQ051K CQ051L)
egen communal_goals = rowmean(CQ051G CQ051F CQ051E CQ051B)
gen political_goals = CQ051K
gen judge_goals = CQ051L

egen agentic_workplace = rowmean(CQ035A CQ035C CQ035D CQ035J)
egen communal_workplace = rowmean(CQ035B CQ035F CQ035G CQ035K CQ035L CQ035M)

egen agentic_satisfaction = rowmean (CQ047A CQ047B  CQ047E CQ047F CQ047G CQ047L CQ047M CQ047P CQ047R)
egen communal_satisfaction = rowmean (CQ047H CQ047I CQ047J CQ047K CQ047O CQ047Q  CQ047S)

gen ag_intellectual = CQ051A 
gen ag_wealth = CQ051C 
gen ag_influencial_person= CQ051D

egen agentic_goals2 = rowmean(CQ051A CQ051C CQ051D CQ051H)

foreach var of varlist agentic_goals agentic_goals2 communal_goals agentic_workplace communal_workplace agentic_satisfaction communal_satisfaction ag_intellectual ag_wealth ag_influencial_person {
	sum `var'
	gen `var'_scale = (`var' -`r(min)') / (`r(max)'-`r(min)')
}


egen discrim_all = rowmean(CQ048_O_1 CQ048_O_2 CQ048_O_3 CQ048_O_4 CQ048_O_5 CQ048_O_6 CQ048_O_7 CQ048_O_8 CQ051L)
rename CQ048_O_1 discrim_comment
rename CQ048_O_2 discrim_assign
rename CQ048_O_3 discrim_client
rename CQ048_O_4 discrim_colleague
rename CQ048_O_5 discrim_other
rename CQ048_O_6 discrim_value


gen n_mentors = CQ044XBRAC

foreach var of varlist CQ045A CQ045B CQ045C CQ045D CQ045E CQ045F CQ045G CQ045H {
	recode `var' 9=.
}


gen spouse_employed = CQ068
recode spouse_employed 9=.

gen spouse_hours = CQ069XBRAC 
gen spouse_income = CQ070XBRAC

gen billable_hours = CQ039XBRAC

egen fem_expertise = rowmean(CQ025D CQ025G CQ025H CQ025I CQ025J CQ025M CQ025N)

gen court = CQ029
recode court 1=5 2=1 3=2 4=3 5=4 else=.

*** labeling variables *** 

label var gender "Gender"
label define gender 0 "women" 1 "men"

label var pid "Party ID"
label define pid 1 "Democrat" 2 "Independent" 3 "Republican"
label var ideo_social "Social policy ideology"
label var ideo_econ "Economic policy ideology"

label var any_children "Any minor children"
label var n_children "Number of minor children"

label var married "Married or partnered"

label var any_debt_still "Still have any debt"

label var pt_child "Part time to care for children"
label var pt_family "Part time to care for family"
label var unemploy_child "Unemployed to care for children"
label var unemploy_family "Unemployed to care for family"
label var employed "Employed full time"

label var law_rank "Law school ranking"

label var communal_law "Practices non-profit or public interest law"
label var current_judge "Currently a judge"
label var current_da "Currently a DA"
label var current_clerk "Currently a clerk"

label var per_work_male "% of workplace who are men"
label var pro_bono_work "Pro-bono hours at work"
label var pro_bono_nonwork "Pro-bono hours outside work"

label var agentic_workplace_scale "Agentic reasons for picking workplace"
label var communal_workplace_scale "Communal reasons for picking workplace"
label var agentic_satisfaction_scale "Agentic satisfaction w work"
label var communal_satisfaction_scale "Communal satisfaction w work"


label variable n_mentors "Number of mentors"


label var agentic_goals_scale "Importance of Agentic Goals"
label var agentic_goals2_scale "Importance of Agentic Goals"
label var communal_goals_scale "Importance of Communal Goals"
label var political_goals "Political Ambition"
label var judge_goals "Judicial Ambition"
label var ag_intellectual_scale "Intellectual challenge"
label var ag_wealth_scale  "Accumulate wealth"
label var ag_influencial_person_scale  "Be influencial person"





label var spouse_employed "Spouse is employed"
label var spouse_hours "Spouse hours worked"
label var spouse_income "Spouse income"
label var billable_hours "Number of billable hours"

label var fem_expertise "Feminine area of expertise"
label var court "How frequently appear in court"

*** saving 

save "$Data\ajd3_cleaned.dta", replace 

keep AJD3_ID ASU_ID age agentic_goals agentic_goals_scale agentic_goals2_scale agentic_goals2 ag_intellectual_scale ag_wealth_scale ag_influencial_person_scale agentic_satisfaction agentic_satisfaction_scale agentic_workplace agentic_workplace_scale any_children any_debt_still billable_hours communal_goals communal_goals_scale communal_law communal_satisfaction communal_satisfaction_scale communal_workplace communal_workplace_scale court current_clerk current_da current_judge discrim_all discrim_assign discrim_client discrim_colleague discrim_comment discrim_other discrim_value edu_debt_remaining employed fem_expertise gender ideo_econ ideo_social judge_goals law_degree_year law_rank lead_all lead_civic lead_gender lead_poladvoc lead_polparty lead_pta married n_children n_mentors network_associations network_committee network_consult network_lunch network_nonprofit network_orgs network_publications network_rectime participation_all participation_civic participation_gender participation_poladvoc participation_polparty participation_pta per_work_male pid political_goals pro_bono_charity pro_bono_nonwork pro_bono_poor pro_bono_work pt_child pt_family spouse_employed spouse_hours spouse_income unemploy_child unemploy_family white court fem_expertise CWT_NAT_NR


foreach var of varlist age agentic_goals agentic_goals_scale agentic_satisfaction ag_intellectual_scale ag_wealth_scale ag_influencial_person_scale agentic_satisfaction_scale agentic_workplace agentic_workplace_scale any_children any_debt_still billable_hours communal_goals communal_goals_scale communal_law communal_satisfaction communal_satisfaction_scale communal_workplace communal_workplace_scale court current_clerk current_da current_judge discrim_all discrim_assign discrim_client discrim_colleague discrim_comment discrim_other discrim_value edu_debt_remaining employed fem_expertise gender ideo_econ ideo_social judge_goals law_degree_year law_rank lead_all lead_civic lead_gender lead_poladvoc lead_polparty lead_pta married n_children n_mentors network_associations network_committee network_consult network_lunch network_nonprofit network_orgs network_publications network_rectime participation_all participation_civic participation_gender participation_poladvoc participation_polparty participation_pta per_work_male pid political_goals pro_bono_charity pro_bono_nonwork pro_bono_poor pro_bono_work pt_child pt_family spouse_employed spouse_hours spouse_income unemploy_child unemploy_family white {
	rename `var' `var'w3
}

gen wave = 3
gen year = 2012

save "$Data\adj3_reduced.dta", replace 

